#ifndef SERVER_TEST_H
#define SERVER_TEST_H

#include <gtest/gtest.h>
#include "test_common.h"
#include "../proto/information.pb.h"
#include <src/message.h>
#include <src/abstract_observer.h>
#include <src/port.h>

class server : public abstract_observer
{
public:
    int counter;

public:
    server() : counter(0) {}

    void receive(const message::msg_handle)
    {
        //TODO: please implement
        counter++;
    }
};

class server_mock
{
};

namespace constants {

const int message_id = 2;
const char* payload = "abc";
} // constants

class server_test : public ::testing::Test
{
protected:
    server s;

public:
	server_test(){}
};

TEST_F(server_test, blah1) {
	message::msg_handle msg(new message(
        constants::message_id, constants::payload, sizeof(constants::payload)));

    s.receive(msg);
    EXPECT_EQ(1, s.counter);
}

TEST_F(server_test, blah2) {
    port p;

    server_mock s_mock; // split into 2 testfiles and use mock!

    EXPECT_TRUE(p.register_observer(&s));

	message::msg_handle msg(new message(
        constants::message_id, constants::payload, sizeof(constants::payload)));

    p.notify(msg);

    EXPECT_EQ(1, s.counter);
}

#endif // SERVER_TEST
